package com.jindy.module.repairMachine.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jindy.common.annotation.Log;
import com.jindy.common.core.controller.BaseController;
import com.jindy.common.core.domain.AjaxResult;
import com.jindy.common.enums.BusinessType;
import com.jindy.module.repairMachine.domain.RepairMachine;
import com.jindy.module.repairMachine.service.IRepairMachineService;
import com.jindy.common.utils.poi.ExcelUtil;
import com.jindy.common.core.page.TableDataInfo;

/**
 * 报修机器管理Controller
 * 
 * @author jindy
 * @date 2023-04-25
 */
@RestController
@RequestMapping("/module/repairMachine")
public class RepairMachineController extends BaseController
{
    @Autowired
    private IRepairMachineService repairMachineService;

    /**
     * 查询报修机器管理列表
     */
    @PreAuthorize("@ss.hasPermi('module:repairMachine:list')")
    @GetMapping("/list")
    public TableDataInfo list(RepairMachine repairMachine)
    {
        startPage();
        List<RepairMachine> list = repairMachineService.selectRepairMachineList(repairMachine);
        return getDataTable(list);
    }

    /**
     * 导出报修机器管理列表
     */
    @PreAuthorize("@ss.hasPermi('module:repairMachine:export')")
    @Log(title = "报修机器管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RepairMachine repairMachine)
    {
        List<RepairMachine> list = repairMachineService.selectRepairMachineList(repairMachine);
        ExcelUtil<RepairMachine> util = new ExcelUtil<RepairMachine>(RepairMachine.class);
        util.exportExcel(response, list, "报修机器管理数据");
    }

    /**
     * 获取报修机器管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:repairMachine:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(repairMachineService.selectRepairMachineById(id));
    }

    /**
     * 新增报修机器管理
     */
    @PreAuthorize("@ss.hasPermi('module:repairMachine:add')")
    @Log(title = "报修机器管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RepairMachine repairMachine)
    {
        return toAjax(repairMachineService.insertRepairMachine(repairMachine));
    }

    /**
     * 修改报修机器管理
     */
    @PreAuthorize("@ss.hasPermi('module:repairMachine:edit')")
    @Log(title = "报修机器管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RepairMachine repairMachine)
    {
        return toAjax(repairMachineService.updateRepairMachine(repairMachine));
    }

    /**
     * 删除报修机器管理
     */
    @PreAuthorize("@ss.hasPermi('module:repairMachine:remove')")
    @Log(title = "报修机器管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(repairMachineService.deleteRepairMachineByIds(ids));
    }
}
